﻿<!DOCTYPE html>

<html>

<head>
    <meta name="viewport" content="width=device-width" />
    <title></title>
    <script src="~/js/frame.js"></script>
</head>

<body>
    <div class="framecontainer">
        <div class="leftcontinaer">
            <div class="cloud-panel">
                <div class="cloud-panel-header ">
                    <div class="cloud-panel-title">类别列表</div>
                </div>
                <div class="cloud-panel-body">
                    <ul id="tree" class="ztree" overflow:auto;"></ul>
                </div>
            </div>
        </div>
        <div class="rightcontinaer">
            <div class="cloud-panel">
                <div class="cloud-panel-header ">
                    <div class="cloud-panel-title">代码项管理</div>
                </div>
                <div class="cloud-panel-body">
                    <div class="listcontainer">
                        <div class="searchop">
                            <div class="btnop">
                                <button class="btn btn-op" type="button" onclick="OpenAdd()"><span class="btntext">新增代码项</span></button>
                                <button class="btn btn-op" type="button" onclick="BatchDelete()"><span class="btntext">批量删除</span></button>
                                <cloud-import id="ImportDMPCode" btntext="导入代码项" url="frame/dmp/codemain/importxml" afterimport="AfterImport()"></cloud-import>
                                <button class="btn btn-op" type="button" onclick="BatchExport()"><span class="btntext">导出代码项</span></button>
                            </div>
                            <div class="btnop">
                                <input id="CodeName" type="text" class="form-control searchinput" placeholder="请输入代码项名称">
                                <button class="btn" type="button" onclick="BindGrid()"><i class="icon icon-search"></i><span class="searchtext">查询</span></button>
                            </div>
                        </div>
                        <div class="tableop">
                            <table class="GridStyle" id="CloudGrid" keyid="CodeGuid" url="oplist" relationpageid="cloudpagination" otherparm="SearchParm" afterbind="AfterBindData">
                                <tr class="HeaderStyle">
                                    <th scope="col" style="width: 10px;" field="check" rowalign="center"></th>
                                    <th scope="col" style="width: 10px;" field="index" rowalign="center">序</th>
                                    <th scope="col" field="CodeName" rowalign="left">代码项名称</th>
                                    <th scope="col" style="width: 100px;" field="function" functionname="GetCodeLevel" rowalign="center">代码类别</th>
                                    <th scope="col" style="width: 50px;" field="SortNum" rowalign="center">排序</th>
                                    <th scope="col" field="function" functionname="ManageCodeItem" rowalign="center" width="100px">代码项管理</th>
                                    <th scope="col" style="width: 50px;" field="EditButton" functionname="GridEdit" rowalign="center">详细</th>
                                </tr>
                            </table>
                        </div>
                        <div class="bottomop">
                            <div class="pageop">
                                <ul class="pagination" id="cloudpagination"></ul>
                            </div>
                        </div>
                    </div>
                </div>

            </div>
        </div>
    </div>

    <script>
        var GroupUrl = GetRootPath() + "frame/base/group/grouptree";
        var GroupGuid = "Top"
        $(function () {
            BindGrid();
            BindTree();
        })
        function BindGrid() {
            BindCloudGrid($("#CloudGrid"))
        }
        function BindTree() {
            CloudPost({ "GroupTag": "SystemCode" }, GroupUrl, function (res) {
                BindMenuTree("tree", res.data, TreeNodeOnClick);
            })
        }
        function SearchParm() {
            return {
                "CodeName": $("#CodeName").val(),
                "GroupGuid": GroupGuid
            };
        }
        function AfterBindData() {

        }
        function OpenAdd() {
            OpenTopDialog("新增代码项", "frame/dmp/codemain/add?groupguid=" + GroupGuid, 400, 800, BindGrid)
        }
        function BatchDelete() {
            var SelectRows = CloudGridChecked($("#CloudGrid"));
            if (SelectRows.length > 0) {
                OpenConfirm("确认删除选中的数据？", function () {
                    CloudPost({ "KeyID": SelectRows }, "opbatchdelete", function (res) {
                        if (res.code == 0) {
                            OpenSuccess("删除成功！", function () {
                                BindGrid();
                            })
                        } else {
                            OpenFail(res.data);
                        }
                    })
                })
            }
        }

        function BatchExport() {
            var SelectRows = CloudGridChecked($("#CloudGrid"));
            if (SelectRows.length > 0) {
                var url = GetRootPath() + "frame/dmp/codemain/exportxml?keyid=" + SelectRows;
                window.open(url);
            }
        }

        function GridEdit(RowData) {
            OpenTopDialog("编辑", "frame/dmp/codemain/edit?codeguid=" + RowData.CodeGuid, 400, 800, BindGrid)
        }
        function TreeNodeOnClick(event, treeId, treeNode, clickFlag) {
            GroupGuid = treeNode.id
            BindGrid();
        }
        function GetCodeLevel(RowData) {
            if (RowData.LevelType == 10) {
                return "一级代码项";
            } else {
                return "多级代码项";
            }
        }
        function ManageCodeItem(RowData) {
            return " <button class='btn btn-op' type='button' onclick=ManageCodeItemClick('" + RowData.CodeGuid + "','" + RowData.LevelType + "')>维护详情</button>";
        }
        function ManageCodeItemClick(MainGuid, LevelType) {
            OpenTopDialog("代码项维护", "frame/dmp/codeitem/list?mainguid=" + MainGuid + "&leveltype=" + LevelType, 600, 1000)
        }
        function AfterImport() {
            OpenSuccess("导入成功！");
            BindGrid();
        }
    </script>
</body>
</html>